package tom.jiafei;
import java.sql.*;
public class QueryBookList{
	String userid;
	String[] list;
	public void setUserid(String str){
		userid=str;
	}
	public String getUserid(){
		return userid;
	}
	public String[] getList(){
		Connection con;
	    Statement sql;
	    ResultSet rs;
	    try{
	    	Class.forName("com.mysql.jdbc.Driver");
	    	}
	    catch(Exception e){}
   
    try{
		String uri = "jdbc:mysql://127.0.0.1:3306/book_store?useUnicode=true&characterEncoding=utf8";
		String user = "root";
		String password = "1e916d4e2405be9e";
		con=DriverManager.getConnection(uri,user,password);
		sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
		rs=sql.executeQuery("SELECT distinct bookno from order_ where userid='"+userid+"'");
		rs.last();
		int count = rs.getRow();
        list=new String[count];
		rs.first();
		int i=0;
		do{
			list[i]=rs.getString(1);
			i++;
		}while(rs.next());
		con.close();
	}
	catch(SQLException e1){}
	return list;
	}
}